1 using System.Collections;
2 using
System.Collections.Generic;
3 using
UnityEngine;
4
5 public
class BulletScript : MonoBehaviour {
6
7     
public Vector3 velocity;
8     
public float powerFactor;
9     
public GameObject hit;
10     
public Vector3 hitOffset = new Vector3(0, 1f, -1f);
11
12     
// Use this for initialization
13     
void Start () {
14         
15     }
16     
17     
// Update is called once per frame
18     
void Update () {
19
20     }
21
22     
void FixedUpdate () {
23         transform.position += velocity * Time.deltaTime;
24     }
25
26     
void OnTriggerEnter2D(Collider2D collider) {
27 // Debug.Log (
"BulletScript.OnTriggerEnter2D()");
28
29 // collider.gameObject.SendMessage (
"TakeDamage", powerFactor);
30
31         
if (collider.gameObject.layer == LayerMask.NameToLayer ("Enemy")) {
32             GameObject hitobj = Instantiate (hit,
this.transform.position + hitOffset, Quaternion.identity);
33             
// Destroy(gameObject);
34             gameObject.SetActive(
false);
35
36             GameObject.Destroy (hitobj,
0.15f);
37         }
38     }
39 }


Gõ tìm kiếm nhanh...